package com.example.fireDet.controller;

import com.example.fireDet.serviceImpl.AWDMatchWebSocket;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Log
@RestController
@RequestMapping("ws")
public class AwdMatchWSTestController {

    @Resource
    AWDMatchWebSocket webSocket;

    @GetMapping("/sendAllWebSocket")
    public String test() {
        String text="你们好！这是websocket群体发送！";
        webSocket.sendAllMessage(text);
        return text;
    }

    @GetMapping("/sendOneWebSocket/{userId}")
    public String sendOneWebSocket(@PathVariable Long userId) {
        String text=userId+" 你好！ 这是websocket单人发送！";
        webSocket.sendOneMessage(userId,text);
        return text;
    }

}

